open(BUFF,"chr22_out_ori_dos.txt") or die "chr22_out_ori.tped no file exists\n";
open(BUFF1,"impute_dosage.txt") or die " beagle_final.txt file not exists\n";
while(<BUFF>)
{
        $line = <BUFF1>;
        chomp($_);
        chomp($line);
        @array = split(" ",$_);
	$rsid = shift(@array);
	shift(@array);
	shift(@array);
        @array1 = split(" ",$line);
        $rsid1 = shift(@array1);
        shift(@array1);
        shift(@array1);
	if($rsid eq $rsid1)
        {
                print "$rsid";
                $n=0;
		$m=0;
                for($i = 0;$i<@array;$i++)
                {
                        $val1 = $array[$i];
                        $val3 = $array1[$i];
			if($val1 ne "NA")
			{
				$m++;
				$n = $n+abs($val1-$val3);
			}
                }
		$temp = ($n/$m);
                print " $n\n";
        }
	else
	{
		print "$rsid ne $rsid1\n";
	}
}

